package com.sky.controller.user;

import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("UserShopController")
@Api(tags = "店铺管理")
@RequestMapping("/user/shop")
public class ShopController {

    private static final String KEY = "SHOP_STATUS";
    private final RedisTemplate redisTemplate;


    @Autowired
    public ShopController(RedisTemplate redisTemplate){
        this.redisTemplate = redisTemplate;
    }

    @GetMapping("/status")
    @ApiOperation("获取营业状态")
    public Result<Integer> getStatus(){
        Integer status = (Integer) this.redisTemplate.opsForValue().get(KEY);
//        if(status == null){
//            return Result.fail("未找到营业状态");
//        }
        return Result.success(status);
    }

}

